<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../../../assert/css/font.css" th:href="@{/assert/css/font.css}"/>
    <link rel="stylesheet" href="../../../assert/css/bootstrap.min.css" th:href="@{/assert/css/bootstrap.min.css}"/>
    <link rel="stylesheet" href="../../../assert/css/plugin/chosen/chosen.css"
          th:href="@{/assert/css/plugin/chosen/chosen.css}"/>
    <link rel="stylesheet" href="../../../assert/css/bootstrap-table.css" th:href="@{/assert/css/bootstrap-table.css}"/>
    <link href="../../../assert/css/animate.min.css" rel="stylesheet" th:href="@{/assert/css/animate.min.css}">
    <link href="../../../assert/css/plugin/toastr/toastr.min.css" rel="stylesheet"
          th:href="@{/assert/css/plugin/toastr/toastr.min.css}">
    <link href="../../../assert/css/plugin/jsTree/style.min.css" rel="stylesheet"
          th:href="@{/assert/css/plugin/jsTree/style.min.css}">
    <link href="../../../assert/css/loaders.css" rel="stylesheet"
          th:href="@{/assert/css/loaders.css}">
    <link rel="stylesheet" href="../../../assert/css/jquery-ui.css" th:href="@{/assert/css/jquery-ui.css}"/>
    <link rel="stylesheet" href="../../../assert/css/index.css" th:href="@{/assert/css/index.css(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"/>
    <style>
        .search_group label.control-label{
            width:105px;
        }
    </style>
</head>
<body>
<a id="basePath" th:href="@{/}"></a>
<div class="wrapper wrapper-content">
    <div class="ibox">
        <div class="tools_bar">
            <div class="pull-left">
                <a href="#" class="btn btn-default active" id="btnSearch" title="隐藏查询条"><i class="fa fa-filter"></i> 隐藏</a>
                <a href="#" class="btn btn-default active" id="refresh"><i class="fa fa-refresh"></i> 刷新</a>
            </div>
            <div class="search_group">
                <div class="circleBox" id="lookExpression">
                    <span class="fa fa-question-circle"  style="cursor: pointer" ></span>
                    <div class="circle">
                        <div class="circle_con" style="display: none">
                            <ul>
                                <li>对于系统质检规则：总命中量 = 系统命中量+人工添加量-人工纠正量</li>
                                <li>对于人工质检规则：总命中量 = 人工质检规则命中量</li>
                                <li>人工添加量：人工添加的系统质检规则命中量</li>
                                <li>人工纠正量：人工纠正的系统质检规则命中量，也是系统误判量</li>
                                <li>申诉率 = 申诉量/总命中量* 100%</li>
                                <li>申诉成功率 = 申诉成功量/总申诉量*100%</li>
                                <li>系统正确率 = （系统命中量 - 人工纠正量） / （系统命中量+人工添加量）*100%</li>
                                <li>系统漏识率 = 人工添加量 / 总命中量*100%</li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="search on">
            <div class="search_group">
                <label class="control-label"><span class="respan">*</span>省份：</label>
                <div class="control-inline">
                    <select type="text" id="pro" value="" class="form-control search_input"></select>
                </div>
            </div>
            <div class="search_group">
                <label class="control-label"><span class="respan">*</span>质检任务名称：</label>
                <div class="control-inline">
                    <select type="text" id="workName" value="" class="form-control search_input"></select>

                </div>
            </div>
            <div class="search_group">
                <label class="control-label">坐席班组：</label>
                <div class="control-inline">
                    <select type="text" id="seatGroup" value="" class="form-control search_input"></select>

                </div>
            </div>
            <div class="search_group">
                <label class="control-label">坐席工号：</label>
                <div class="control-inline">
                    <input type="text" id="seatId" value="" class="form-control search_input" autocomplete="off">
                </div>
            </div>
            <div class="search_group">
                <label class="control-label">坐席姓名：</label>
                <div class="control-inline">
                    <input type="text" id="seatName" value="" class="form-control search_input" autocomplete="off">
                </div>
            </div>
            <div class="search_group">
                <label class="control-label">质检规则名称：</label>
                <div class="control-inline">
                    <select type="text" id="ruleName" value="" class="form-control search_input"></select>
                </div>
            </div>
            <div class="search_group">
                <label class="control-label">规则属性：</label>
                <div class="control-inline">
                    <select type="text" id="rulePro" value="" class="form-control search_input"></select>
                </div>
            </div>
            <div class="search_group">
                <label class="control-label">分值属性：</label>
                <div class="control-inline">
                    <select type="text" id="scorePro" value="" class="form-control search_input"></select>
                </div>
            </div>
            <div class="search_group">
                <label class="control-label">致命性：</label>
                <div class="control-inline">
                    <select type="text" id="repeatPhone" value="" class="form-control search_input"></select>
                </div>
            </div>
            <div class="search_group">
                <label class="control-label">满意度：</label>
                <div class="control-inline">
                    <select type="text" id="agree" value="" class="form-control search_input"></select>
                </div>
            </div>
            <div class="search_group">
                <label class="control-label">是否重复来电：</label>
                <div class="control-inline">
                    <select type="text" id="reCallFlag" value="" class="form-control search_input"></select>
                </div>
            </div>
            <div class="search_group">
                <label class="control-label">通话时间：</label>
                <div class="control-inline">
                    <input placeholder="开始日期" class="form-control layer-date search_input" id="callStartTime" autocomplete="off"> -
                    <input placeholder="结束日期" class="form-control layer-date search_input" id="callEndTime" autocomplete="off">
                </div>
            </div>
            <div class="search_group">
                <button id="search" class="btn  btn-primary">查询</button>
                <button id="reset" class="btn  btn-default">重置</button>
                <button id="export" class="btn  btn-default">导出列表</button>
            </div>
        </div>
        <table id="myTable"></table>
    </div>
</div>
<form action="" id="formDetail" class="hidden" target="_blank">
    <input type="text" name="workName">
    <input type="text" name="seatGroup">
    <input type="text" name="seatId">
    <input type="text" name="callStartTime">
    <input type="text" name="callEndTime">
    <input type="text" name="pro">
    <input type="text" name="seatName">
    <input type="text" name="ruleId">
    <input type="text" name="satisfaction">
    <input type="text" name="reCallFlag">
    <input type="text" name="ruleType">
</form>
<form action="" id="exportForm" class="hidden" method="post">
    <input type="text" id="provinceCodeE" name="provinceCode">
    <input type="text" id="callStartTimeE" name="callStartTime">
    <input type="text" id="callEndTimeE" name="callEndTime">
    <input type="text" id="workIdE" name="workId">
    <input type="text" id="groupIdE" name="groupId">
    <input type="text" id="seatIdE" name="seatId">
    <input type="text" id="ruleIdE" name="ruleId">
    <input type="text" id="ruleNameE" name="ruleName">
    <input type="text" id="useForE" name="useFor">
    <input type="text" id="signScoreE" name="signScore">
    <input type="text" id="fatefulE" name="fateful">
    <input type="text" id="satisfactionE" name="satisfaction">
    <input type="text" id="reCallFlagE" name="reCallFlag">

</form>
<div th:text="${pro}" id="proL" class="hidden"></div>
<div th:text="${workId}" id="workIdL" class="hidden"></div>
<script src="../../../assert/js/jquery.js" th:src="@{/assert/js/jquery.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/bootstrap.min.js" th:src="@{/assert/js/bootstrap.min.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/plugin/bootstrap-table/bootstrap-table.min.js"
        th:src="@{/assert/js/plugin/bootstrap-table/bootstrap-table.min.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/plugin/bootstrap-table/bootstrap-table-mobile.min.js"
        th:src="@{/assert/js/plugin/bootstrap-table/bootstrap-table-mobile.min.js}"></script>
<script src="../../../assert/js/plugin/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"
        th:src="@{/assert/js/plugin/bootstrap-table/locale/bootstrap-table-zh-CN.min.js}"></script>
<script src="../../../assert/js/plugin/toastr/toastr.min.js"
        th:src="@{/assert/js/plugin/toastr/toastr.min.js}"></script>
<script src="../../../assert/js/base.js" th:src="@{/assert/js/base.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/jquery-ui.min.js" th:src="@{/assert/js/jquery-ui.min.js}"></script>
<script src="../../../assert/js/plugin/layer/laydate/laydate.js"
        th:src="@{/assert/js/plugin/layer/laydate/laydate.js}"></script>
<script src="../../../assert/js/changeTime.js" th:src="@{/assert/js/changeTime.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/plugin/jsTree/jstree.min.js"
        th:src="@{/assert/js/plugin/jsTree/jstree.min.js}"></script>
<script src="../../../assert/js/plugin/chosen/chosen.jquery.js"
        th:src="@{/assert/js/plugin/chosen/chosen.jquery.js}"></script>
<script src="../../../assert/js/contabs.min.js" th:src="@{/assert/js/contabs.min.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/common.js" th:src="@{/assert/js/common.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script>
    //项目名称
    var basePath = $("#basePath").attr("href");
    var resize = {
        init: function () {
            resize.me();
            $(window).resize(function () {
                resize.me();
            })
        },
        me: function () {
            var winW = $(window).width();
            var winH = $(window).height();
            $(".ibox").width(winW - 20);
            $(".ibox").height(winH - 20);
            bs.autoTableHeight($('#myTable'),winH -$(".tools_bar").height()-22-$(".search").height())
        }
    };
    var TableInit = function () {
        var oTableInit1 = new Object();
        var url = basePath + "rest/phone-statistics/get-rule-count";
        var height = ($(window).height() -$(".tools_bar").height()-22-$(".search").height());
        //初始化Table
        oTableInit1.Init = function () {
            $('#myTable').bootstrapTable("destroy");
            var obj={
                url: url,         //请求后台的URL（*）
                method: 'post',                      //请求方式（*）
                cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                pagination: true,                   //是否显示分页（*）
                height:height,
                queryParams: function (params) {
                    var temp = {   //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                        pageNum: params.offset/params.limit,   //页面大小
                        pageSize: params.limit,
                        provinceCode: $("#pro").val(),
                        workId: $("#workName").val(),
                        groupId: $("#seatGroup").val(),
                        seatId: $.trim($("#seatId").val()),
                        seatName: $.trim($("#seatName").val()),
                        callStartTime: $("#callStartTime").val(),
                        callEndTime: $("#callEndTime").val(),
                        ruleId: $("#ruleName").val(),
                        useFor: $("#rulePro").val(),
                        fateful: $("#repeatPhone").val(),
                        signScore: $("#scorePro").val(),
                        ruleName: tools.getNameInIdRule($("#ruleName").val()),
                        reCallFlag: $("#reCallFlag").val(),
                        satisfaction: $("#agree").val()
                    };
                    return temp;
                },//传递参数（*）
                responseHandler: function (res) {
                    tools.tableData = res.data;
                    return {
                        "total": res.count,//总页数
                        "rows": res.data   //数据
                    };
                },
                sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
                pageNumber: 1,                       //初始化加载第一页，默认第一页
                pageSize: 10,                       //每页的记录行数（*）
                pageList: [10, 25, 50, 100],        //可供选择的每页的行数（*）
                search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
                contentType: "application/x-www-form-urlencoded",
                strictSearch: true,
                showColumns: false,                  //是否显示所有的列
                showRefresh: false,                  //是否显示刷新按钮
                minimumCountColumns: 2,             //最少允许的列数
                clickToSelect: true,                //是否启用点击选中行
                showToggle: false,                    //是否显示详细视图和列表视图的切换按钮
                cardView: false,                    //是否显示详细视图
                detailView: false,
                cellStyle: {
                    css: {"background-color": "#fff"}
                },//是否显示父子表
                columns:tools.tableColumns(),
                onLoadSuccess: function (data) {  //加载成功时执行
                    resize.me();
                    if (!data.total||data.total == 0) {
                        var src=basePath+"/assert/image/nodata.png";
                        $(".no-records-found").find("td").html('<img src="'+src+'" th:src="@{/assert/image/nodata.png}" style="width:165px;" alt="">');
                    }
                },
                onLoadError: function () {  //加载失败时执行
                    var src = basePath + "/assert/image/nodata.png";
                    $(".no-records-found").find("td").html('<img src="' + src + '" th:src="@{/assert/image/nodata.png}" style="width:165px;" alt="">');
                },
                formatLoadingMessage: function () {
                    return '<div class="loaded">' +
                        '<div class="loader">' +
                        '<div class="loader-inner line-scale-pulse-out">' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '</div>' +
                        '</div>' +
                        '</div>' +
                        '<div>请稍等，数据正在加载中...</div>';
                }
            };
            $('#myTable').bootstrapTable(obj);
        };
        return oTableInit1;
    };
    var TableInitOne = function () {
        var oTableInit = new Object();
        //初始化Table
        oTableInit.Init = function () {
            $('#myTable').bootstrapTable("destroy");
            var obj={
                data:[],
                columns:tools.tableColumns(),
                onPostBody:function(){
                    $(".no-records-found").find("td").html("<div style='height:50px;line-height: 50px;'>亲，请选择必选条件哦！</div>")
                }
            };
            $('#myTable').bootstrapTable(obj);
        };
        return oTableInit;
    };
    var tools = {
        tableData: [],
        seatArr: [],
        reCallFlagArr: [],
        agreeArr:[],
        deadlinessArr:[],
        testProArr: [],//规则属性
        scoreProArr: [],//分值属性
        taskArr: [],
        ruleArr: [{
            "name": "全部",
            "value": ""
        }
        ],
        seatIdArr:[],
        seatNameArr:[],
        seatAllArr:[],
        proArr:[],
        num:0,
        params:{
            workId: ''
        },
        init: function () {
            tools.getRuleFlag();//获取规则属性 状态
            tools.getScoreFlag();//获取分值属性 状态
            tools.getSatStatus();//获取满意度 状态
            tools.getDeadliness();//获取致命性 状态
            tools.getReCallFlag();//获取重复来电 状态
            bs.dataTime("#callStartTime","#callEndTime");//时间初始化
            tools.tabSearch();
            tools.search();
            tools.reset();
            tools.refresh();
            tools.enterSearch();
            tools.export();
            tools.selectProvince();
            if($("#workIdL").text()!=""){//如果是从其他页面跳转过来
                tools.initSearch();
            }else{
                tools.getSeatGroup(bs.getXInY(tools.proArr, "id", "value", $("#pro").val()));//获取坐席班组数据
                tools.getSeatId(bs.getXInY(tools.proArr, "id", "value", $("#pro").val()), $("#seatGroup").val());//获取坐席工号数据
                tools.getTaskNameData($("#pro").val());//获取质检任务数据
                tools.getRuleName($("#workName").val(), "", "");//获取规则数据
                tools.resetTable();
                if($("#pro").val()!=-1 && $("#workName").attr("disabled")){
                    $("#search").click();
                }
            }
            $("#pro").on("change", function (event, sel) {
                var code = sel.selected;
                var id = bs.getXInY(tools.proArr, "id", "value", code);
                tools.getTaskNameData($("#pro").val());
                tools.getSeatGroup(id);
                tools.getSeatId(id,$("#seatGroup").val());
            });
            $("#seatGroup").on("change", function (event, sel) {
                var id = sel.selected;
                tools.getSeatId(bs.getXInY(tools.proArr, "id", "value", $("#pro").val()), id);
            });
            $("#seatId").on("change",function(event, sel){
                var id=$(this).val();
                for(var i=0;i<tools.seatAllArr.length;i++){
                    if(tools.seatAllArr[i].account==id){
                        $("#seatName").val(tools.seatAllArr[i].realName);
                    }
                }
            });
            $("#seatName").on("change",function(event, sel){
                var id=$(this).val();
                for(var i=0;i<tools.seatAllArr.length;i++){
                    if(tools.seatAllArr[i].realName==id){
                        $("#seatId").val(tools.seatAllArr[i].account);
                    }
                }
            });
            $("#workName").on("change", function (event, sel) {
                var id = sel.selected;
                tools.params.workId = id;
                tools.getRuleName(id, "", "");
            });
            $("#repeatPhone").on("change", function (event, sel) {
                var val = sel.selected;
                if(val != ""){
                    $("#scorePro").val('-1').prop('disabled',true).trigger("chosen:updated");
                }else{
                    $("#scorePro").prop('disabled',false).trigger("chosen:updated");
                    if($("#scorePro").val() == 1){
                        $("#scorePro").val('').trigger("chosen:updated");
                    }
                }
            });
            $("#scorePro").on("change", function (event, sel) {
                var val = sel.selected;
                if(val == "1"){
                    $("#repeatPhone").prop('disabled',true).val('').trigger("chosen:updated");
                }else{
                    $("#repeatPhone").prop('disabled',false).trigger("chosen:updated");
                }
            });
            $("#lookExpression").hover(function(){
                $(this).find(".circle_con").show();
            },function(){
                $(this).find(".circle_con").hide();
            });
        },
        getDeadliness:function(){
            var dataArr = bs.getStatus("rule_nature");
            Object.assign(tools.deadlinessArr,dataArr);//es6复制数组的方法
            tools.deadlinessArr[0].name="请选择";
            bs.selectDown($("#repeatPhone"), tools.deadlinessArr);
        },
        getSatStatus: function () {
            var dataArr = bs.getStatus("audio_satisfaction");
            Object.assign(tools.agreeArr,dataArr);//es6复制数组的方法
            tools.agreeArr[0].name="请选择";
            bs.selectDown($("#agree"), tools.agreeArr);
        },
        getReCallFlag:function(){
            var dataArr = bs.getStatus("recall_flag");
            Object.assign(tools.reCallFlagArr,dataArr);//es6复制数组的方法
            tools.reCallFlagArr[0].name="请选择";
            bs.selectDown($("#reCallFlag"), tools.reCallFlagArr);
        },
        getSeatId: function (areaId, seatGroupId) {
            tools.seatAllArr=bs.getSeatData(areaId, seatGroupId,"");
            if($("#userIdentity",parent.document).text()=="0"){
                var arr=bs.getMeSeatData("");
                for(var i=0;i<arr.length;i++){
                    tools.seatIdArr.push(arr[i].account);
                    tools.seatNameArr.push(arr[i].realName);
                }
            }else{
                for(var i=0;i<tools.seatAllArr.length;i++){
                    tools.seatIdArr.push(tools.seatAllArr[i].account);
                    tools.seatNameArr.push(tools.seatAllArr[i].realName);
                }
            }
            $("#seatId").autocomplete({
                source: tools.seatIdArr
            });
            $("#seatName").autocomplete({
                source: tools.seatNameArr
            });
            if($("#userIdentity",parent.document).text()=="0"){
                if(tools.seatIdArr.length==1){
                    $("#seatId").val(tools.seatIdArr[0]).prop("disabled",true);
                    $("#seatName").val(tools.seatNameArr[0]).prop("disabled",true);
                }else{
                    $("#seatId").val("").prop("disabled",false);
                    $("#seatName").val("").prop("disabled",false);
                }
            }

        },
        getScoreFlag: function () {
            tools.scoreProArr = bs.getStatus("score_flag");
            tools.scoreProArr[0].name="请选择";
            bs.selectDown($("#scorePro"), tools.scoreProArr, "");
        },
        getRuleFlag: function () {
            tools.testProArr = bs.getStatus("rule_property");
            tools.testProArr[0].name="请选择";
            bs.selectDown($("#rulePro"), tools.testProArr, "");
        },
        getTaskNameData: function (code) {
            tools.taskArr = bs.getTaskNameData(code);
            tools.taskArr[0].name="请选择";
            bs.selectDown($("#workName"), tools.taskArr, "");
        },
        getRuleName: function (workId, modelId, ruleTypeId) {
            var url = basePath + "rest/pending-task-detail/get-rule-by-tree";
            $.ajax({
                type: "post",
                url: url,
                dataType: "json",
                async: false,
                data: {
//                    pageNum:0,   //页面大小
//                    pageSize:10,
                    workId: workId,
                    modelId: modelId,
                    ruleTypeId: ruleTypeId
                },
                success: function (data) {
                    if (data.code == 0) {
                        var dataArr = data.data;
                        tools.ruleArr = [{
                            "name": "全部",
                            "value": ""
                        }];
                        for (var i = 0; i < dataArr.length; i++) {
                            var obj = {};
                            obj.name = dataArr[i].ruleName;
                            obj.value = dataArr[i].ruleId;
                            obj.modelId = dataArr[i].modelId;
                            tools.ruleArr.push(obj);
                        }
                    }
                }
            });
            tools.ruleArr[0].name="请选择";
            bs.selectDown($("#ruleName"), tools.ruleArr);
        },
        getSeatGroup: function (id) {
            if($("#userIdentity",parent.document).text()=="0"){
                tools.seatArr =bs.getMeSeatGroupData();
                bs.selectDown($("#seatGroup"), tools.seatArr,"");
            }else{
                tools.seatArr =bs.getSeatGroupData(id);
                bs.selectDownNoDisabled($("#seatGroup"), tools.seatArr,"");
            }
            tools.seatArr[0].name="请选择";

        },
        getNameInIdGroup: function (id) {//根据坐席id获取name
            var name = "";
            for (var i = 0; i < tools.seatArr.length; i++) {
                if (tools.seatArr[i].value == id) {
                    name = tools.seatArr[i].name;
                    break;
                }
            }
            return name;
        },
        getNameInIdRule: function (id) {//根据致命性id获取name
            var name = "";
            for (var i = 0; i < tools.ruleArr.length; i++) {
                if (tools.ruleArr[i].value == id) {
                    name = tools.ruleArr[i].name;
                    break;
                }
            }
            return name;
        },
        selectProvince: function () {
            tools.proArr = bs.getProvince();
            tools.proArr.unshift({"name":"请选择","value":"-1"})
            bs.selectDown($("#pro"), tools.proArr, "");
            if($("#spanId",parent.document).attr("data-procode")!=""){
                if(tools.proArr.length==3){
                    $("#pro").val(tools.proArr[2].value).prop("disabled", true).trigger("chosen:updated");
                }
            }
        },
        changeState: function (value, arr) {
            var str = "";
            for (var i = 0; i < arr.length; i++) {
                if (value == arr[i].value) {
                    str = arr[i].name
                }
            }
            return str;
        },
        tabSearch: function () {
            var search = $(".search");
            $("#btnSearch").on("click", function () {
                if (search.hasClass("on")) {
                    search.slideUp();
                    search.removeClass("on");
                    $("#btnSearch").html('<i class="fa fa-filter"></i> 查询').attr("title", "显示查询条");
                } else {
                    search.slideDown();
                    search.addClass("on");
                    $("#btnSearch").html('<i class="fa fa-filter"></i> 隐藏').attr("title", "隐藏查询条");
                }

            });
        },
        search: function () {
            $("#search").on("click", function () {
                var res = tools.searchValidate();
                if (res) {
                   tools.tableRefresh();
                }
            })
        },
        searchValidate: function () {
            var res = false;
            if ($("#pro").val() == "-1") {
                toastrCog.error("请选择省份！", 2000)
            } else if ($("#workName").val() == "") {
                toastrCog.error("请选择质检任务名称！", 2000)
            } else {
                res = true;
            }
            return res;
        },
        tableRefresh: function () {
            if(tools.num==0){
                var oTable = new TableInit();
                oTable.Init();
            }else{
                $("#myTable").bootstrapTable('refreshOptions', {pageNumber:1});
                $("#myTable").bootstrapTable('refresh');
            }
            tools.num++;
        },
        reset: function () {
            $("#reset").on("click", function () {
                params.workId = ''
                $("#repeatPhone").prop('disabled',false).trigger("chosen:updated");
                $("#scorePro").prop('disabled',false).trigger("chosen:updated");
                bs.resetSearch($(".search"));
                //时间重置
                if($("#laydate_box").length>0){
                    bs.resetTimeElems("#callStartTime","#callEndTime");
                }
                //省份班组坐席重置
                if($("#spanId",parent.document).attr("data-procode")==""){
                    $("#pro").val("-1").trigger("chosen:updated");
                    tools.getSeatGroup($("#pro").val());
                    tools.getSeatId($("#pro").val(),$("#seatGroup").val());
                }
                if($("#userIdentity",parent.document).text()!="0"){
                    $("#seatGroup").val("-1").trigger("chosen:updated").prop("disabled",false);
                    tools.getSeatId(bs.getXInY(tools.proArr,'id','value',$("#pro").val()),$("#seatGroup").val());
                    $("#seatId").val("").prop("disabled",false);
                    $("#seatName").val("").prop("disabled",false);
                }
                //任务重置
                if( $("#pro").val()=="-1"){
                    tools.taskArr=[{
                        "name": "请选择",
                        "value": ""
                    }];
                    bs.selectDown($("#workName"), tools.taskArr, "");
                    $("#workName").val("").attr("disabled",false).trigger("chosen:updated");
                }
                //规则重置
                if($("#workName").val()==""){
                    tools.ruleArr=[{
                        "name": "请选择",
                        "value": ""
                    }];
                    bs.selectDown($("#ruleName"), tools.taskArr, "");
                    $("#ruleName").val("").attr("disabled",false).trigger("chosen:updated");
                }
                tools.resetTable();
            })
        },
        resetSelect: function ($obj) {
            $obj.val("");
            $obj.trigger("chosen:updated");
        },
        refresh: function () {
            $("#refresh").on("click", function () {
                $("#myTable").bootstrapTable('refresh');
            })
        },
        enterSearch: function () {
            $("body").on("keyup", function (e) {
                var code = e.charCode || e.keyCode;
                if (code == 13) {
                    //此处编写用户敲回车后的代码
                    $("#search").click();
                }
            })
        },
        export: function () {
            $("#export").on("click", function () {
                var res = tools.searchValidate();
                if (res) {
                    $("#export").html("请求中...请稍后").prop("disabled",true);
                    var url = basePath + "rest/phone-statistics/get-rule-count";
                    $.ajax({
                        type: "post",
                        url: url,
                        dataType: "json",
                        async: false,
                        data: {
                            pageNum: 0,  //页面大小
                            pageSize:10,
                            provinceCode: $("#pro").val(),
                            workId: $("#workName").val(),
                            groupId: $("#seatGroup").val(),
                            seatId: $.trim($("#seatId").val()),
                            seatName: $.trim($("#seatName").val()),
                            callStartTime: $("#callStartTime").val(),
                            callEndTime: $("#callEndTime").val(),
                            ruleId: $("#ruleName").val(),
                            useFor: $("#rulePro").val(),
                            fateful: $("#repeatPhone").val(),
                            signScore: $("#scorePro").val(),
                            ruleName: tools.getNameInIdRule($("#ruleName").val()),
                            reCallFlag: $("#reCallFlag").val(),
                            satisfaction: $("#agree").val()
                        },
                        success: function (data) {
                            if (data.code == 0) {
                                if(data.data.length>0){
                                    var form = $("#exportForm");
                                    form.attr("action", basePath + "/rest/phone-statistics/export-rule-mes");
                                    $("#provinceCodeE").val($("#pro").val());
                                    $("#callStartTimeE").val($("#callStartTime").val());
                                    $("#callEndTimeE").val($("#callEndTime").val());
                                    $("#workIdE").val($("#workName").val());
                                    $("#groupIdE").val($("#seatGroup").val());
                                    $("#seatIdE").val($.trim($("#seatId").val()));
                                    $("#ruleIdE").val($("#ruleName").val());
                                    $("#ruleNameE").val(tools.getNameInIdRule($("#ruleName").val()));
                                    $("#useForE").val($("#rulePro").val());
                                    $("#signScoreE").val($("#scorePro").val());
                                    $("#fatefulE").val($("#repeatPhone").val());
                                    $("#satisfactionE").val($("#agree").val());
                                    $("#reCallFlagE").val($("#reCallFlag").val());
                                    form[0].submit();
                                }else{
                                    toastrCog.error("没有可导出的数据哦！")
                                }
                            }else{
                                toastrCog.error("导出异常！")
                            }
                        },
                        complete:function(){
                            $("#export").html("导出列表").prop("disabled",false);
                        }
                    });
                }

            })

        },
        jumpDetail:function(){
            var form=$("#formDetail");
            var provinceCodeC = $("#pro").val();
            var seatGroupC = $("#seatGroup").val();
            var seatIdC = $("#seatId").val();
            var seatNameC = $("#seatName").val();
            var callStartTimeC = $("#callStartTime").val();
            var callEndTimeC = $("#callEndTime").val();
            var workNameC = $("#workName").val();
            var satisfactionC = $("#agree").val();
            var reCallFlagC = $("#reCallFlag").val();
            form.find("input[name='pro']").val(bs.getXInY(tools.taskArr,'pro','value',tools.params.workId));
            form.find("input[name='seatGroup']").val(seatGroupC);
            form.find("input[name='seatId']").val(seatIdC);
            form.find("input[name='seatName']").val(seatNameC);
            form.find("input[name='callStartTime']").val(callStartTimeC);
            form.find("input[name='callEndTime']").val(callEndTimeC);
            form.find("input[name='workName']").val(workNameC);
            form.find("input[name='satisfaction']").val(satisfactionC);
            form.find("input[name='reCallFlag']").val(reCallFlagC);
        },
        jumpFomatter:function(value, row, code, txt){
            tools.jumpDetail();
            $("#formDetail").find("input[name='ruleId']").val(row.ruleId);
            $("#formDetail").find("input[name='ruleType']").val(code);
            var params=$("#formDetail").serialize();
            var href=basePath + "/rest/page/speechDetail?"+params;
            if(value!=0){
                return '<a href="'+href+'" title="查看详情"  class="J_menuItem" data-index="规则详情1"  data-txt="规则统计-语音详情-'+txt+'" data-href="/rest/page/speechDetail">'+value+'</a>'
            }else{
                return value+''
            }

        },
        getNowTime:function(){
            var endTime=dateFormatUtil(new Date().getTime());
            var str=endTime.split(" ")[0];
            var startTime=str.substr(0,str.length-2)+"01"+" "+"00:00:00";
            $("#callStartTime").val(startTime);
            $("#callEndTime").val(endTime);
        },
        initSearch:function(){
            $("#pro").val($("#proL").text()).trigger("chosen:updated");
            tools.getTaskNameData($("#pro").val());
            $("#workName").val($("#workIdL").text()).trigger("chosen:updated");
            tools.getRuleName($("#workName").val(), "", "");
            tools.getSeatGroup(bs.getXInY(tools.proArr,"id","value",$("#pro").val()));
            tools.getSeatId(bs.getXInY(tools.proArr,"id","value",$("#pro").val()), $("#seatGroup").val());
            if($("#pro").val()!=-1 || $("#workName").val()!=""){
                var oTable = new TableInit();
                oTable.Init();
            }
            tools.num=0;
        },
        resetTable:function(){
            var oTableOne = new TableInitOne();
            oTableOne.Init();
            tools.num=0;
        },
        tableColumns:function(){
            return [
                {
                    align: "center",
                    halign: "center",
                    title: '序号',//标题  可不加
                    width: 60,
                    formatter: function (value, row, index) {
                        var getOptions = $("#myTable").bootstrapTable('getOptions');
                        var pagenum = getOptions.pageNumber;
                        var pagesize = getOptions.pageSize;
                        var st = (pagenum - 1) * pagesize;
                        return (st + index + 1) + "";
                    }
                },
                {
                    align: "left",
                    halign: "center",
                    field: 'provinceCode',
                    title: '省份',
//                        sortable: true,
                    formatter: function (value, row, index) {
                        return bs.filterData(bs.getXInY(tools.proArr,"name","value",value));
                    }
                }, {
                    align: "center",
                    halign: "center",
                    field: 'groupId',
                    title: '坐席班组',
//                        sortable: true,
                    formatter: function (value, row, index) {
                        return bs.filterData(bs.getXInY(tools.seatArr,"name","value",value));
                    }
                },
                {
                    align: "center",
                    halign: "center",
                    field: 'seatId',
                    title: '坐席工号',
//                        sortable: true,
                    formatter:function(value, row, index){
                        return bs.filterData(value);
                    }
                },
                {
                    align: "center",
                    halign: "center",
                    field: 'ruleName',
                    title: '规则名称',
                    formatter:function(value, row, index){
                        return '<div style="width:250px">'+value+'</div>';
                    }
//                        sortable: true
                },
                {
                    align: "center",
                    halign: "center",
                    field: 'ruleType',
                    title: '规则分类',
//                        sortable: true
                },
                {
                    align: "center",
                    halign: "center",
                    field: 'useFor',
                    title: '规则属性',
                    formatter: function (value, row, index) {
                        var str = "";
                        if (value == "1") {
                            str = "人工";
                        } else  if (value == "0"){
                            str = "系统";
                        }
                        return "<span>" + str + "</span>";
                    }
//                        sortable: true
                },
                {
                    align: "center",
                    halign: "center",
                    field: 'signScore',
                    title: '分值属性',
                    formatter: function (value, row, index) {
                        return "<span>" + bs.changeState(value,tools.scoreProArr) + "</span>";
                    }
//                        sortable: true
                }, {
                    align: "center",
                    halign: "center",
                    field: 'fateful',
                    title: '致命性',
                    formatter: function (value, row, index) {
                        var str = "";
                        if (value == "1") {
                            str = "是";
                        } else if (value == "0"){
                            str = "否";
                        }
                        return "<span>" + str + "</span>";
                    }
//                        sortable: true
                }, {
                    align: "center",
                    halign: "center",
                    field: 'hitCount',
                    title: '总命中量',
                    formatter: function (value, row, index) {
                        return tools.jumpFomatter(value, row, 'hitCount','总命中量')
                    }
                }, {
                    align: "center",
                    halign: "center",
                    field: 'sysHitCount',
                    title: '系统命中量',
                    formatter: function (value, row, index) {
                        return tools.jumpFomatter(value, row, 'sysHitCount','系统命中量')
                    }
                }, {
                    align: "center",
                    halign: "center",
                    field: 'leakageCount',
                    title: '人工添加量',
                    formatter: function (value, row, index) {
                        return tools.jumpFomatter(value, row, 'leakageCount','人工添加量')
                    }
                }, {
                    align: "center",
                    halign: "center",
                    field: 'accuracyCount',
                    title: '人工纠正量',
                    formatter: function (value, row, index) {
                        return tools.jumpFomatter(value, row, 'accuracyCount','人工纠正量')
                    }
                }, {
                    align: "center",
                    halign: "center",
                    field: 'appealCount',
                    title: '申诉量',
                    formatter: function (value, row, index) {
                        return tools.jumpFomatter(value, row, 'appealCount','申诉量')
                    }
                }, {
                    align: "center",
                    halign: "center",
                    field: 'rejectCount',
                    title: '驳回量',
                    formatter: function (value, row, index) {
                        return tools.jumpFomatter(value, row, 'rejectCount','驳回量')
                    }
                }, {
                    align: "center",
                    halign: "center",
                    field: 'appealOkCount',
                    title: '申诉成功量',
                    formatter: function (value, row, index) {
                        return tools.jumpFomatter(value, row, 'appealOkCount','申诉成功量')
                    }
                }, {
                    align: "center",
                    halign: "center",
                    field: 'appeal',
                    title: '申诉率',
//                        sortable: true,
                }, {
                    align: "center",
                    halign: "center",
                    field: 'appealOk',
                    title: '申诉成功率',
//                        sortable: true,
                }, {
                    align: "center",
                    halign: "center",
                    field: 'accuracy',
                    title: '系统正确率',
                }, {
                    align: "center",
                    halign: "center",
                    field: 'leakage',
                    title: '系统漏识率',
                }
            ]
        }
    };
    $(function () {
        tools.init();
        resize.init();
    })
</script>
</body>
</html>